const app=getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {

    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        this.data.Uid=options.Uid,
        this.setData({
            title:options.Uname
        })
        console.log(this.data.Uid)
        this.getres()
    },
    onShow:function(){
        this.getres()
    },
    getres: function(){
        wx.request({
            url:`${app.globalData.url}/me-homepage/me-fanlist?Bid=`+this.data.Uid+"&Uid="+wx.getStorageSync('Uid'),
            success:res=>{
                console.log(res.data);
                this.setData({
                    list:res.data
                })
            }
        })
    },
    changeState:function(e){
        let Times;
        let time=new Date()
        let year = time.getFullYear()
        let month = time.getMonth() + 1
        let date = time.getDate()
        let hours = time.getHours()
        let minute = time.getMinutes()
        let second = time.getSeconds()
        if (month < 10) { month = '0' + month }
        if (date < 10) { date = '0' + date }
        if (hours < 10) { hours = '0' + hours }
        if (minute < 10) { minute = '0' + minute }
        if (second < 10) { second = '0' + second }
        Times=year + '-' + month + '-' + date + ' ' + hours + ':' + minute + ':' + second
        wx.request({
            url:`${app.globalData.url}/me-homepage/me-fanlist`,
            method:'POST',
            data:{
                Uid:wx.getStorageSync('Uid'),
                Bid:e.currentTarget.dataset.state.Uid,
                Time:Times,
                Astate:e.currentTarget.dataset.state.Astate=='+关注'?'已关注':'+关注'
            },
            success:res=>{
                this.getres();
            }
        })
    },
    jumpPage:function(e){
        let uid=wx.getStorageSync('Uid');
        let bid=e.currentTarget.id;
        wx.navigateTo({
            url:'/pages/me-homepage/me-homepage?Uid='+uid+'&Bid='+bid
        })
    },
    jumpAtten:function(){
        wx.navigateTo({
            url:'/pages/me-attenlist/me-attenlist?Uid='+this.data.Uid
        })
    }
})